import { ref, computed } from 'vue'
import { defineStore } from 'pinia'

const useThemeStore = defineStore('theme', () => {

    const themeLabel = ref('light')
    function setTheme(label: string) {
        const themeList = ['light', 'dark']
        if (themeList.indexOf(label) > -1)
            themeLabel.value = label
        else throw Error('主题不存在:' + label)
    }

    function getThemeLabel() {
        return themeLabel.value
    }
    return {
        themeLabel
        , setTheme, getThemeLabel
    }
})
export default useThemeStore